package com.igeek.javase.ch04.FZtest;

/**
 * @author chenmin
 * 2023/7/12 19:45
 * @description TODO
 */

/*
 * 2.封装一个皇帝类，里面有姓名，在位时间，政绩，描述4个属性，
 * 提供一个方法用来显示所有属性，私有化这些属性并提供对应的get以及set方法，
 * 并在测试类中测试。
 */

public class Emperor {
    private String name;
    private int time;
    private String achievement;
    private String description;

    public String getName() {
        return this.name;
    }

    public String setName(String name) {
        this.name = name;
        return name;
    }

    public int getTime() {
        return this.time;
    }

    public int setTime(int time) {
        this.time = time;
        return time;
    }

    public String getAchievement() {
        return this.achievement;
    }

    public String setAchievement(String achievement) {
        this.achievement = achievement;
        return achievement;
    }

    public String getDescription() {
        return this.description;
    }

    public String setDescription(String description) {
        this.description = description;
        return description;
    }

    public void print() {
        System.out.println("该皇帝的名字是" + name);
        System.out.println("在位时间长达" + time + "年");
        System.out.println("功绩有" + achievement);
        System.out.println("描述为" + description);
    }

    public static void main(String[] args) {
        Emperor e1 = new Emperor();
        e1.name = "李世民";
        e1.time = 40;
        e1.achievement = "贞观之世";
        e1.description = "千古一帝";
        e1.print();

    }
}
